/*
** serv_monitor2.c for serf/zappy in /home/Smaxo/Travail/zappy-2015-2014s-renard_g/serv-src
**
** Made by maximilien addari
** Login   <addari_m@epitech.net>
**
** Started on  Mon Jul  9 15:00:37 2012 maximilien addari
** Last update Thu Jul 19 18:29:22 2012 pierrick druart
*/

#include	"server.h"

static void	serv_make_cmd(t_game *game, t_client *client, int x, int y)
{
  client->send->concat(client->send, " ");
  client->send->concat_value(client->send, game->obj[x][y].inv[FOOD]);
  client->send->concat(client->send, " ");
  client->send->concat_value(client->send, game->obj[x][y].inv[LINEMATE]);
  client->send->concat(client->send, " ");
  client->send->concat_value(client->send, game->obj[x][y].inv[DERAUMERE]);
  client->send->concat(client->send, " ");
  client->send->concat_value(client->send, game->obj[x][y].inv[SIBUR]);
  client->send->concat(client->send, " ");
  client->send->concat_value(client->send, game->obj[x][y].inv[MENDIANE]);
  client->send->concat(client->send, " ");
  client->send->concat_value(client->send, game->obj[x][y].inv[PHIRAS]);
  client->send->concat(client->send, " ");
  client->send->concat_value(client->send, game->obj[x][y].inv[THYSTAME]);
}

void		serv_ppo(t_client *client, t_game *game, t_client *graphic)
{
  (void)game;
  graphic->send->concat(graphic->send, "ppo ");
  graphic->send->concat_value(graphic->send, client->sock);
  graphic->send->concat(graphic->send, " ");
  graphic->send->concat_value(graphic->send, client->gamer->coord.x);
  graphic->send->concat(graphic->send, " ");
  graphic->send->concat_value(graphic->send, client->gamer->coord.y);
  graphic->send->concat(graphic->send, " ");
  graphic->send->concat_value(graphic->send, client->gamer->direction);
  graphic->send->concat(graphic->send, "\n");
}

void		serv_pin(t_client *client, t_game *game, t_client *graphic)
{
  graphic->send->concat(graphic->send, "pin ");
  graphic->send->concat_value(graphic->send, client->sock);
  graphic->send->concat(graphic->send, " ");
  graphic->send->concat_value(graphic->send, client->gamer->coord.x);
  graphic->send->concat(graphic->send, " ");
  graphic->send->concat_value(graphic->send, client->gamer->coord.y);
  serv_make_cmd(game, graphic, client->gamer->coord.x, client->gamer->coord.y);
  graphic->send->concat(graphic->send, "\n");
}

void		serv_bct(t_client *client, t_game *game, t_client *graphic)
{
  graphic->send->concat(graphic->send, "bct ");
  graphic->send->concat_value(graphic->send, client->gamer->coord.x);
  graphic->send->concat(graphic->send, " ");
  graphic->send->concat_value(graphic->send, client->gamer->coord.y);
  serv_make_cmd(game, graphic, client->gamer->coord.x, client->gamer->coord.y);
  graphic->send->concat(graphic->send, "\n");
}

void		serv_pnw(t_client *client, t_game *game, t_client *graphic)
{
  (void)game;
  graphic->send->concat(graphic->send, "pnw ");
  graphic->send->concat_value(graphic->send, client->sock);
  graphic->send->concat(graphic->send, " ");
  graphic->send->concat_value(graphic->send, client->gamer->coord.x);
  graphic->send->concat(graphic->send, " ");
  graphic->send->concat_value(graphic->send, client->gamer->coord.y);
  graphic->send->concat(graphic->send, " ");
  graphic->send->concat_value(graphic->send, client->gamer->direction);
  graphic->send->concat(graphic->send, " ");
  graphic->send->concat_value(graphic->send, client->gamer->level);
  graphic->send->concat(graphic->send, " ");
  graphic->send->concat(graphic->send, client->gamer->team->name);
  graphic->send->concat(graphic->send, "\n");
}
